drop procedure if exists test; delimiter // create procedure test() begin declare i int; set i=0; while i<300000 do insert into testfororder(newid,name,age) select concat(i,name),FLOOR(18 + (RAND() * 12)) from test1; set i=i+1; end while; end// delimiter ; 调用存储过程: call test();
insert into sequence(newid,name,age) select * from testfororder;
数据量根据自己需求可以多次导入
4、查看sequence测试表数据:
1 2 3 4 5 6 7
select count(*) from sequence; +----------+ | count(*) | +----------+ | 12600000 | +----------+ 1 row in set (2.83 sec)
5、在newid没有索引的情况下,in和or的对比:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
repl@db 16:14: [aaaa]> select * from sequence where newid in (116670,116677,116684,116691,116698,116705,116719,116726); +----------+--------+-----------+------+ | id | newid | name | age | +----------+--------+-----------+------+ | 100003 | 116670 | 2381lucy | 26 | ... | 76679494 | 116726 | 2382bobo | 21 | +----------+--------+-----------+------+ 56 rows in set (4.47 sec)
select * from sequence where newid =116670 or newid = 116677 or newid = 116684 or newid =116691 or newid = 116698 or newid=116705 or newid=116719 or newid=116726; +----------+--------+-----------+------+ | id | newid | name | age | +----------+--------+-----------+------+ | 100003 | 116670 | 2381lucy | 26 | ... | 76679494 | 116726 | 2382bobo | 21 | +----------+--------+-----------+------+ 56 rows in set (6.77 sec)
create index newid_ind on sequence(newid); select * from sequence where newid in (116670,116677,116684,116691,116698,116705,116719,116726); +----------+--------+-----------+------+ | id | newid | name | age | +----------+--------+-----------+------+ | 100003 | 116670 | 2381lucy | 26 | ... | 76679494 | 116726 | 2382bobo | 21 | +----------+--------+-----------+------+ 56 rows in set (0.00 sec)
select * from sequence where newid =116670 or newid = 116677 or newid = 116684 or newid =116691 or newid = 116698 or newid=116705 or newid=116719 or newid=116726; +----------+--------+-----------+------+ | id | newid | name | age | +----------+--------+-----------+------+ | 100003 | 116670 | 2381lucy | 26 | ... | 76679494 | 116726 | 2382bobo | 21 | +----------+--------+-----------+------+ 56 rows in set (0.01 sec)